//
//  WmcLogManager.swift
//  YPWatermarkCamera
//
//  Created by 赵新 on 2022/8/12.
//

import UIKit
import YPBedrock

extension WmcLogManager {
    enum LogType {
        case `default`

        case appDelegate
        case jiGuang
        case evoke

        case appStateManager
        case dateManager
        case decibeManager
        case dbManager
        case fontManager
        case amapLocationManager
        case motionManager
        case navigatorManager
        case downloadManager
        case uploadQueueManager

        case wmcVideo
        case wmcImage
        case mediaRequest
        case watermarkDetailModel
        case delloc
        case lifeCycle
        case permissions
        case location

        struct Info {
            var prefix: String
        }

        var info: Info {
            switch self {
            case .default:
                return .init(prefix: "🆓普通")
            case .appDelegate:
                return .init(prefix: "🟢AppDelegate")
            case .jiGuang:
                return .init(prefix: "📢极光")
            case .evoke:
                return .init(prefix: "😴唤起")

            case .dateManager:
                return .init(prefix: "🕐时间管理")
            case .appStateManager:
                return .init(prefix: "App状态管理")
            case .decibeManager:
                return .init(prefix: "🔊分贝管理")
            case .dbManager:
                return .init(prefix: "🗄数据库管理")
            case .fontManager:
                return .init(prefix: "📁字体管理")
            case .amapLocationManager:
                return .init(prefix: "📍高德管理")
            case .motionManager:
                return .init(prefix: "🏇运动管理")
            case .navigatorManager:
                return .init(prefix: "⛓路由管理")
            case .downloadManager:
                return .init(prefix: "📥下载管理")
            case .uploadQueueManager:
                return .init(prefix: "📤上传管理")

            case .wmcVideo:
                return .init(prefix: "🎬视频对象")
            case .wmcImage:
                return .init(prefix: "🎆图片对象")
            case .mediaRequest:
                return .init(prefix: "🔗媒体请求")
            case .watermarkDetailModel:
                return .init(prefix: "💦水印模型")
            case .delloc:
                return .init(prefix: "💣销毁")
            case .lifeCycle:
                return .init(prefix: "❤️生命周期")
            case .permissions:
                return .init(prefix: "🔐用户权限")
            case .location:
                return .init(prefix: "📌定位")
            }
        }
    }
}

/// 打印日志
/// - Parameter log: 日志内容
func WmcPrint(_ log: String) {
    WmcLogManager.Log(log)
}

// MARK: - [WmcLogManager]

class WmcLogManager: WmcBaseVM {
    /// 是否展示Log
    static var isShowLog: Bool = true

    /// 打印日志
    /// - Parameter log: 日志内容
    static func Log(_ log: String) {
        DebugLog(type: .default, log: log)
    }

    /// 日志
    /// - Parameters:
    ///   - type: 日志类型
    ///   - log: 日志内容
    static func DebugLog(type: LogType, log: String) {
        #if DEBUG
            guard isShowLog else { return }
            let date = Date().yp.string("MM-dd HH:mm:ss")
            let prefix = "📷[\(type.info.prefix)日志]"
            let log = "\(prefix)(\(date))➡️：\(log)"
            WatermarkCameraLib.Log(log)
        #endif
    }
}
